function DB_Run2Maintenance(flag,PF_name,blade,auto){
    let new_steps=['核对'+PF_name+'名称、编号及位置正确。'];
    let Switch=PF_name.match(/箱\s*(\w+)\s*开关/)[1];
    let Blade_demo=[
        '拉开'+Switch+'1刀闸。',
        '检查'+Switch+'1刀闸在拉开位置。',
    ]
    let Auto_demo=[
        '汇报调度（申请进行遥控）。',
        '再经调度令。',
        '切换'+Switch+'开关“远方/就地”转换开关至“就地”位置。',
        '退出'+Switch+'开关保护合闸压板。',
        '退出'+Switch+'开关重合闸压板。',
        '断开'+Switch+'开关操作电源空气开关。',
    ]
    let Blade_blank=blade==1? Blade_demo:Array.from({length:Blade_demo.length},()=> '');
    let Auto_blank=auto==true? Auto_demo:Array.from({length:Auto_demo.length},()=> '');
    let GroundConnection=Switch+'40';
    //转热备用
    if(flag[0]){
        new_steps.push(Auto_blank[0]);
        new_steps.push(Auto_blank[1]);
        new_steps.push(Auto_blank[2]);
        new_steps.push(Auto_blank[3]);
        new_steps.push(Auto_blank[4]);
        new_steps.push('检查'+Switch+'开关SF6气压表气压指示正常。');
        new_steps.push('检查'+Switch+'开关带电指示器显示有电。');
        new_steps.push('断开'+Switch+'开关。');
        new_steps.push('检查'+Switch+'开关在分闸位置。');
        new_steps.push('检查'+Switch+'开关带电指示器显示无电。');
    }
    //转冷备用
    if(flag[1]){
        if(!flag[0]){
            new_steps.push('检查'+Switch+'开关在分闸位置。');
            new_steps.push(Auto_blank[2]);
            new_steps.push(Auto_blank[3]);
            new_steps.push(Auto_blank[4]);
        }
        new_steps.push(Blade_blank[0]);
        new_steps.push(Blade_blank[1]);
        new_steps.push(Auto_blank[5]);
        new_steps.push('在'+Switch+'开关操作把手上悬挂“禁止合闸，线路有人工作”标志牌。');
    }
    //转检修
    if(flag[2]){
        new_steps.push('合上'+GroundConnection+'地刀。');
        new_steps.push('检查'+GroundConnection+'地刀在合上位置。');
    }

    return new_steps.filter(item => item!='')
}

function DB_Maintenance2Run(flag,PF_name,blade,auto){
    let new_steps=['核对'+PF_name+'名称、编号及位置正确。'];
    let Switch=PF_name.match(/箱\s*(\w+)\s*开关/)[1];
    let Blade_demo=[
        '合上'+Switch+'1刀闸。',
        '检查'+Switch+'1刀闸在合上位置。',
    ]
    let Auto_demo=[
        '合上'+Switch+'开关操作电源空气开关。',
        '投入'+Switch+'开关保护合闸压板。',
        '投入'+Switch+'开关重合闸压板。',
        '切换'+Switch+'开关“远方/就地”转换开关至“远方”位置。',
        '汇报调度（申请进行遥控）。',
        '再经调度令。',
        '切换'+Switch+'开关“远方/就地”转换开关至“就地”位置。',
        '切换'+Switch+'开关“远方/就地”转换开关至“远方”位置。',
    ]
    let Blade_blank=blade==1? Blade_demo:Array.from({length:Blade_demo.length},()=> '');
    let Auto_blank=auto==true? Auto_demo:Array.from({length:Auto_demo.length},()=> '');
    let GroundConnection=Switch+'40';
    new_steps.push('检查'+Switch+'开关带电指示器显示无电。');
    new_steps.push('检查'+Switch+'开关SF6气压表气压指示正常。');
    //转冷备用
    if(flag[0]){
        
        new_steps.push('取下'+Switch+'开关操作把手上悬挂“禁止合闸，线路有人工作”标志牌。');
        new_steps.push('拉开'+GroundConnection+'地刀。');
        new_steps.push('检查'+GroundConnection+'地刀在拉开位置。');
        new_steps.push(Auto_blank[0]);
    }
    //转热备用
    if(flag[1]){
        new_steps.push('检查'+Switch+'开关在分闸位置。');
        new_steps.push(Blade_blank[0]);
        new_steps.push(Blade_blank[1]);
        new_steps.push(Auto_blank[1]);
        new_steps.push(Auto_blank[2]);
        new_steps.push(Auto_blank[3]);
    }
    //转运行
    if(flag[2]){
        new_steps.push(Auto_blank[4]);
        new_steps.push(Auto_blank[5]);
        new_steps.push(Auto_blank[6]);
        new_steps.push('合上'+Switch+'开关。');
        new_steps.push('检查'+Switch+'开关在合闸位置。');
        new_steps.push('检查'+Switch+'开关带电指示器显示有电。');
        new_steps.push(Auto_blank[7]);

    }

    return new_steps.filter(item => item!='')
}



export function BoxOutput(PF_name,before,after,blade,type){
    // let RodNum=PF_name.match(/#([0-9]+)\s*杆*塔*/)[1];
    const Boxmodels={
        '运行-热备用':DB_Run2Maintenance([1,0,0],PF_name,blade,type),
        '运行-冷备用':DB_Run2Maintenance([1,1,0],PF_name,blade,type),
        '运行-检修':DB_Run2Maintenance([1,1,1],PF_name,blade,type),
        '热备用-冷备用':DB_Run2Maintenance([0,1,0],PF_name,blade,type),
        '热备用-检修':DB_Run2Maintenance([0,1,1],PF_name,blade,type),
        '冷备用-检修':DB_Run2Maintenance([0,0,1],PF_name,blade,type),
        '检修-冷备用':DB_Maintenance2Run([1,0,0],PF_name,blade,type),
        '检修-热备用':DB_Maintenance2Run([1,1,0],PF_name,blade,type),
        '检修-运行':DB_Maintenance2Run([1,1,1],PF_name,blade,type),
        '冷备用-热备用':DB_Maintenance2Run([0,1,0],PF_name,blade,type),
        '冷备用-运行':DB_Maintenance2Run([0,1,1],PF_name,blade,type),
        '热备用-运行':DB_Maintenance2Run([0,0,1],PF_name,blade,type),
    }
    let steps=Boxmodels[before+'-'+after];
    console.log(steps);
    // let Loc=PF_name.match(/杆*塔*\s*[\u4e00-\u9fa5]+公用台变*/)[0].substring(1).replace(/\s+/g,'');
    let Loc=PF_name;
    let Renwu='将'+PF_name+'后段线路由'+before+'转'+after;
    addticket2page(Loc,Renwu,steps)
}